// song.h

// 2008-05-01 17:05:14 (Jake): created

#ifndef song_h
#define song_h

#include <vector>

struct SongNote {
	//int time;
	//int length;
	float time;
	float length;
	int band;
	int type;
	int level;

	bool operator<(SongNote& n) const { return time < n.time || (time == n.time && level < n.level); }
};

struct SongTempo {
	int midiTime;
	float time;
	int tempo;

	// tempo is defined as number of microseconds between quarter notes

	SongTempo() { }
	SongTempo(int midiTime, float time, int tempo) : midiTime(midiTime), time(time), tempo(tempo) { }

	bool operator<(const SongTempo& t) const { return time < t.time; }
};

typedef std::vector<SongNote> SongNotes;
typedef std::vector<SongTempo> SongTempoList;

class Song : public osg::Referenced {
public:
	Song(const std::string& path);

	void loadInfo();
	void loadImages();
	void loadNotes();
	void loadMusic();

	const std::string& getPath() const { return _path; }
	std::string getSongFile() const;
	std::string getGuitarFile() const;

	SongNotes& getNotes() { return _notes; }
	const SongNotes& getNotes() const { return _notes; }

	SongTempoList& getTempoList() { return _tempoList; }
	const SongTempoList& getTempoList() const { return _tempoList; }

	float getBaseBPM();

protected:
	std::string _path;
	SongNotes _notes;
	SongTempoList _tempoList;
	int _ticksPerBeat;
};

#endif